package com.springcloud.feignconsumer.web;

import com.springcloud.feignconsumer.entity.User;
import com.springcloud.feignconsumer.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author AL
 */
@RestController
public class ConsumerController {

    @Autowired
    private HelloService helloService;

    @RequestMapping(value = "/feign-consumer",method = RequestMethod.GET)
    public User helloConsumer(){
        return helloService.hello("xiaoqiang");
    }

    @RequestMapping(value = "/feign-consumer1",method = RequestMethod.GET)
    @ResponseBody
    public String helloConsumer2(){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(helloService.hello("lucy")).append("\n");
        stringBuilder.append(helloService.hello("jack")).append("\n");
        stringBuilder.append(helloService.hello("jack",25)).append("\n");
        stringBuilder.append(helloService.hello(new User("jack",25))).append("\n");
        return stringBuilder.toString();
    }
}
